Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

elasticsearch

Package Overview
Dependencies
Maintainers
2
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elasticsearch

The official low-level Elasticsearch client for Node.js and the browser.

  • 5.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
200K
increased by17.53%
Maintainers
2
Weekly downloads
 
Created

What is elasticsearch?

The elasticsearch npm package is a client library for interacting with Elasticsearch, a distributed search and analytics engine. This package allows developers to perform a variety of operations such as indexing documents, searching, and managing indices within an Elasticsearch cluster.

What are elasticsearch's main functionalities?

Indexing Documents

This feature allows you to index documents into an Elasticsearch index. The code sample demonstrates how to create a client, connect to an Elasticsearch node, and index a document into 'my-index'.

const { Client } = require('@elastic/elasticsearch');
const client = new Client({ node: 'http://localhost:9200' });

async function run() {
  await client.index({
    index: 'my-index',
    document: {
      title: 'Test Document',
      content: 'This is a test document.'
    }
  });
  console.log('Document indexed');
}
run().catch(console.log);

Searching Documents

This feature allows you to search for documents within an Elasticsearch index. The code sample demonstrates how to search for documents in 'my-index' where the title matches 'Test'.

const { Client } = require('@elastic/elasticsearch');
const client = new Client({ node: 'http://localhost:9200' });

async function run() {
  const result = await client.search({
    index: 'my-index',
    query: {
      match: { title: 'Test' }
    }
  });
  console.log(result.hits.hits);
}
run().catch(console.log);

Managing Indices

This feature allows you to manage indices in Elasticsearch. The code sample demonstrates how to create a new index called 'my-new-index'.

const { Client } = require('@elastic/elasticsearch');
const client = new Client({ node: 'http://localhost:9200' });

async function run() {
  await client.indices.create({
    index: 'my-new-index'
  });
  console.log('Index created');
}
run().catch(console.log);

Other packages similar to elasticsearch

FAQs

Package last updated on 09 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc